package com.changgou;

import io.jsonwebtoken.Claims;
import io.jsonwebtoken.JwtBuilder;
import io.jsonwebtoken.Jwts;
import io.jsonwebtoken.SignatureAlgorithm;
import org.junit.Test;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import tk.mybatis.spring.annotation.MapperScan;

import java.util.Date;

@SpringBootApplication
@EnableEurekaClient
@MapperScan(basePackages = {"com.changgou.system.dao"})
public class SystemApplication {
    public static void main(String[] args) {
        long l = System.currentTimeMillis();
        l += 1000000000L;
        Date date = new Date(l);
        SpringApplication.run(SystemApplication.class);
        JwtBuilder builder = Jwts.builder().setId("666")
                .setSubject("东莞")
                .setIssuedAt(new Date())
                .setExpiration(date)
                .claim("roles", "admin")
                .signWith(SignatureAlgorithm.HS256, "comchen");
        System.out.println(builder.compact());

            String token="eyJhbGciOiJIUzI1NiJ9.eyJqdGkiOiI2NjYiLCJzdWIiOiLkuJzojp4iLCJpYXQiOjE1OTE2MTc3MzgsImV4cCI6MTU5MjYxNzcyNywicm9sZXMiOiJhZG1pbiJ9.Xbx2WSRmRqwiFZ72ejixMAet0SA_-BLX_1va-89pzYY";
            Claims claims=Jwts.parser().setSigningKey("comchen").parseClaimsJws(token).getBody();
            System.out.println(claims);

    }


}
